package com.config;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {


    /**
     *   FanoutExchange 广播类型
     *   DirectExchange 直连型
     *   TopicExchange 主题
     * @return
     */
    @Bean
    public DirectExchange directExchange()
    {
        //交换机名称，是否持久，是否直动删除
        return new DirectExchange("directExchange",true,false);
    }

    /**
     * 队列
     * @return
     */
    @Bean
    public Queue miaoshaQueue()
    {
        return new Queue("miaoshaQueue");
    }


    @Bean
    public Binding  directExchange_queue1()
    {
        //是com.sunjob.这里只能一级
        return BindingBuilder.bind(miaoshaQueue()).to(directExchange()).with("miaosha");
    }


}
